using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace MoniterPLC
{
    /// <summary>
    /// 工位状态转换器
    /// </summary>
    public class StatusConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is StationStatus status)
            {
                switch (status)
                {
                    case StationStatus.Running:
                        return "运行中";
                    case StationStatus.Abnormal:
                        return "异常";
                    case StationStatus.Waiting:
                    default:
                        return "待运行";
                }
            }
            return "未知";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    /// <summary>
    /// 工位状态颜色转换器
    /// </summary>
    public class StatusBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool isRunning)
            {
                return isRunning ? Brushes.Green : Brushes.Gray;
            }
            return Brushes.Red;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}